#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from functools import wraps
import configparser

config = configparser.ConfigParser()
config.read("configure.conf")


def setting(obj):
    _instance = obj(config.get("mysql", "host"), config.get("mysql", "port"))

    @wraps(obj)
    def wrapper(*args, **kwargs):
        if len(args) == 0 and len(kwargs) == 0:
            return _instance
        return obj(*args, **kwargs)

    return wrapper


@setting
class Foo(object):
    def __init__(self, host, port):
        self.host = host
        self.port = port

m1 = Foo()
m2 = Foo()
print(m1)
print(m2)
f = Foo("1.1.1.1", 2000)
print(f)